package fiarredundant;

public class RootNode extends Node {
    // Children is never going to hold a RootNode, therefore TreeNode adds some kind of security
    private TreeNode[] children;

    public RootNode(int degree, int value) {
        super(null, value);
        children = new TreeNode[degree];
    }

    @Override
    public boolean isLeaf() {
        for(Node n: children) {
            if(n!= null) return false;
        }
        return true;
    }
    // A node is complete iff the number of children nodes is equal to the degree of the binary tree
    public boolean isCompleteNode() {
        for(Node n: children) {
            if(n==null) return false;
        }
        return true;
    }

    public TreeNode getChild(int childNumber) {
        return children[childNumber];
    }

    public void setChild(int childNumber, TreeNode n) {
        children[childNumber] = n;
    }


    public TreeNode[] getChildren() {
        return children;
    }

    //TODO: This method seems unecessarily dangerous, check to see if it's really needed
    public void setChildren(TreeNode[] children) {
        this.children = children;
    }
}
